create table [Tour]
(
	 [TourId] int identity(1, 1) primary key
	,[TourName] nvarchar(128)
	,[BeginDate] datetime
	,[EndDate] datetime
	,[CreatedBy] int
	,[CreatedDate] datetime
	,[UpdatedBy] int
	,[UpdatedDate] datetime
	,[Status] int
)
go

CREATE PROCEDURE TourGet
	@TourId int
AS
SELECT *
FROM [Tour]
WHERE [Tour].[TourId] = @TourId
GO

CREATE PROCEDURE TourList
AS
SELECT *
FROM [Tour]
ORDER BY TourId DESC
GO

CREATE PROCEDURE TourInsert
	 @TourName nvarchar(128)
	,@BeginDate datetime
	,@EndDate datetime
	,@CreatedBy int
	,@CreatedDate datetime
	,@UpdatedBy int
	,@UpdatedDate datetime
	,@Status int
AS

INSERT INTO Tour (
	 [TourName]
	,[BeginDate]
	,[EndDate]
	,[CreatedBy]
	,[CreatedDate]
	,[UpdatedBy]
	,[UpdatedDate]
	,[Status]
	
) VALUES (
	 @TourName
	,@BeginDate
	,@EndDate
	,@CreatedBy
	,@CreatedDate
	,@UpdatedBy
	,@UpdatedDate
	,@Status
	
)

select SCOPE_IDENTITY()
GO

CREATE PROCEDURE TourUpdate
	@TourId int, 
	@TourName nvarchar(128), 
	@BeginDate datetime, 
	@EndDate datetime, 
	@CreatedBy int, 
	@CreatedDate datetime, 
	@UpdatedBy int, 
	@UpdatedDate datetime, 
	@Status int 

AS

UPDATE Tour SET
	   [TourName] = @TourName
	   ,[BeginDate] = @BeginDate
	   ,[EndDate] = @EndDate
	   ,[CreatedBy] = @CreatedBy
	   ,[CreatedDate] = @CreatedDate
	   ,[UpdatedBy] = @UpdatedBy
	   ,[UpdatedDate] = @UpdatedDate
	   ,[Status] = @Status
WHERE [Tour].[TourId] = @TourId
GO

CREATE PROCEDURE TourDelete
	@TourId int
AS
DELETE FROM Tour
WHERE [Tour].[TourId] = @TourId
GO